#include "Pawn.h"

Pawn::Pawn(enum FigureColor color) : Figure(color)
{
}

QString Pawn::getImage() const
{
    if(color == BLACK)
        return "./images/blackpawn.png";
    else
        return "./images/whitepawn.png";
}

AllMoves Pawn::moves() const
{
    AllMoves m;
    int x, y, position[2];

    Position::position2index(currentPosition, position);

    x = position[1];
    y = position[0];

    if(!isWhite()) {
        if(y == 1) {
            QVector <int> coords(2), coords2(2);
            coords[0] = y + 1;
            coords[1] = x;
            coords2[0] = y + 2;
            coords2[1] = x;
            m.append(coords);
            m.append(coords2);
        } else {
            if(y + 1 <= 7) {
                QVector <int> coords(2);
                coords[0] = y + 1;
                coords[1] = x;
                m.append(coords);
            }
        }
    } else {
        if(y == 6) {
            QVector <int> coords(2), coords2(2);
            coords[0] = y - 1;
            coords[1] = x;
            coords2[0] = y - 2;
            coords2[1] = x;
            m.append(coords);
            m.append(coords2);
        } else {
            if(y - 1 >= 0) {
                QVector <int> coords(2);
                coords[0] = y - 1;
                coords[1] = x;
                m.append(coords);
            }
        }
    }

    return m;
}
